<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<c:set var="AVALIABLE" value="<%=ConstantDB.AVALIABLE%>"></c:set>
<c:set var="UNAVALIABLE" value="<%=ConstantDB.UNAVALIABLE%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="FROM_TRANSFER" value="<%=ConstantDB.FROM_TRANSFER%>"></c:set>
<c:set var="FROM_ORIGINAL" value="<%=ConstantDB.FROM_ORIGINAL%>"></c:set>
<c:set var="COMMEND_TYPE_KLG" value="<%=ConstantDB.COMMEND_TYPE_KLG%>"></c:set>

<div class="dirbar3">
	<a href="<c:url value='/home.do'/>">首页 </a> >> 
</div>

<c:choose>
	<c:when test="${not empty article}">
		<c:if test="${page.pageIndex < 2}">
			<div class="topic_view">
				<div class="topic_tit">
					<c:out value="${article.title}"></c:out>
				</div>
				<div class="topic_notice">
				作者：<ms:user type="nickname" link="true" userid="${article.userId}" nickname="${article.nickname}" style="a2"></ms:user>
				&nbsp;&nbsp;&nbsp;
				发表时间：<fmt:formatDate value="${article.createTime}" pattern="yyyy-MM-dd HH:mm"/>
				&nbsp;&nbsp;&nbsp;
				<ms:commend type="${COMMEND_TYPE_KLG}" id="${article.articleid}"></ms:commend>
				</div>
				<div class="topic_content">
				<jsp:include page="/${article.htmlPath}"></jsp:include>
				</div>
			</div>
		</c:if>
		<div id="article_reply_new" class="topic_view" style="display:none"></div>
		<c:forEach var="articleReply" items="${page.items}" varStatus="status">
			<c:choose>
				<c:when test="${articleReply.enabled == AVALIABLE}">
					<div class="topic_view">
						<div class="topic_notice">
							作者：<ms:user type="nickname" link="true" userid="${articleReply.userId}" nickname="${articleReply.nickname}"></ms:user>
							&nbsp;&nbsp;&nbsp;
							<fmt:formatDate value="${articleReply.createTime}" pattern="yyyy-MM-dd HH:mm"/>
						</div>
						<div class="topic_content">
							<c:out value="${articleReply.content}"></c:out>
						</div>
					</div>
				</c:when>
				<c:otherwise>
				</c:otherwise>
			</c:choose>
		</c:forEach>
		<div style="font-size:12pt;margin:10px 0 0 0;float:left;width:1000px;">
			<jsp:include page="/common/pager.jsp"></jsp:include>
		</div>
		<div class="thread_new">
			<div class="thread_new_tit">注意：非登陆用户没有发表信息的权利。黄，暴力信息请不要发表</div>
			<div id="div_articlReply_error" class="thread_new_error" style="display:none">
			</div>
			<form id="f_new_articleReply" action="<c:url value='/article/reply.do' />" method="post">
				<input type="hidden" name="reply.articleid" value="${article.articleid}"/>
				<textarea id="articleReply_content" name="reply.content" rows="150" cols="80" style="width:600px;height:300px"><c:out value='${reply.content}'/></textarea>
				<br/>
			</form>
			<a href="javascript:ajaxSubmitFollow('f_new_articleReply', 'div_articlReply_error', 'article_reply_new', 'articleReply_content');">回复</a>
		</div>
	</c:when>
	<c:otherwise>
		<tiles:insertDefinition name="html.klg.article.notexist"></tiles:insertDefinition>
	</c:otherwise>
</c:choose>
<script>
function ajaxSubmitFollow(formid, errorid, newid, contentid){
	$("#"+errorid).html();
	$("#"+errorid).css("display", "none");
	$.ajax({
		type : "POST",
		url : $("#"+formid).attr('action'),
		data : $("#"+formid).serialize(),
		dataType:"xml", 
		timeout:20000,
		success : function(data){
			if($(data).find('result').text().toUpperCase().indexOf("TRUE") < 0){
				$("#"+errorid).html($(data).find('content').text());
				$("#"+errorid).css("display", "block");
			}else{
				var content = "<div class='topic_notice'>作者：<c:out value='${nickname}'/>&nbsp;&nbsp;&nbsp;"+ formatDate(new Date(), "yyyy-MM-dd HH:mm"); 
				content = content + "</div><div class='topic_content'>";
				content = content + "您的回复正等待审核....<br/><br/>";
				content = content + $("#"+contentid).val();
				content = content + "</div>";
				alert(content);
				$("#"+newid).html(content);
				$("#"+newid).css("display", "block");
				$("#"+contentid).val('');
			}
		},
		error: function(){
		}
	});
}
</script>